PROGRAM main
  VAR
    // 反转按钮
    bBackwardButton AT %IX1.2 : BOOL;
    // 正转按钮
    bForwardButton AT %IX1.1 : BOOL;
    // 停止按钮
    bStopButton AT %IX1.4 : BOOL;
    // 电机正转控制输出
    bMotorForward AT %QX0.1 : BOOL;
    // 电机反转控制输出
    bMotorBackward AT %QX0.2 : BOOL;
  END_VAR

bMotorForward := (bForwardButton OR bMotorForward) AND (NOT(bStopButton) AND NOT(bMotorBackward));
bMotorBackward := (bBackwardButton OR bMotorBackward) AND (NOT(bStopButton) AND NOT(bMotorForward));
END_PROGRAM
